Imports System.Windows.Forms
Imports dao
Imports System.Data
Imports DTO
Public Class NGUOIDUNGBus
    Inherits AbstractBus
    Public Sub New()
    End Sub
    Public Sub New(ByVal ConnectionString As KetNoiDto)
        ketnoi = ConnectionString
    End Sub
#Region "Xử Lý"
    Public Sub Them(ByVal Dto As NGUOIDUNGdto)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.Them(Dto)
    End Sub
    Public Sub Xoa(ByVal ID As System.Int32)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.Xoa(ID)
    End Sub
    Public Sub sua(ByVal Dto As NGUOIDUNGdto)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.sua(Dto)
    End Sub
#End Region
    Public Function LayBangTable() As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBang()
        Return Dao
    End Function
    Public Function LayBangTableIlist() As IList
        Dim Dao As New NguoidungDao(ketnoi)
        Dim aList As New ArrayList
        For i As Integer = 0 To Dao.Rows.Count - 1
            Dim dtoNGUOIDUNG As NGUOIDUNGdto = LayBangDTo(i, Dao)
            aList.Add(dtoNGUOIDUNG)
        Next
        Return aList
    End Function
    Public Function LayBangTableSQL(ByVal sql As String) As DataTable
        Dim Dao As New AbstractDao(sql, sql, ketnoi)
        Return Dao
    End Function
    Public Sub suaTenDangNhap(ByVal TenDangNhap As System.String, ByVal ID As System.Int32)
        Dim dao As New NguoidungDao(ketnoi)
        dao.suaTenDangNhap(TenDangNhap, ID)
    End Sub
    Public Sub suaMatKhau(ByVal MatKhau As System.String, ByVal ID As System.Int32)
        Dim dao As New NguoidungDao(ketnoi)
        dao.suaMatKhau(MatKhau, ID)
    End Sub
    Public Sub suaIdNV(ByVal IdNV As System.Int32, ByVal ID As System.Int32)
        Dim dao As New NguoidungDao(ketnoi)
        dao.SuaIdNV(IdNV, ID)
    End Sub
    Public Sub suaIdQuyen(ByVal IdQuyen As System.Int32, ByVal ID As System.Int32)
        Dim dao As New NguoidungDao(ketnoi)
        dao.SuaIdQuyen(IdQuyen, ID)
    End Sub
    Public Function LayBangTable(ByVal ID As System.Int32) As DataTable
        Dim Dao As New NguoidungDao(ID, ketnoi)
        Return Dao
    End Function
    Public Function LayBangTableIlist(ByVal ID As System.Int32) As IList
        Dim Dao As New NguoidungDao(ID, ketnoi)
        Dim aList As New ArrayList
        For i As Integer = 0 To Dao.Rows.Count - 1
            Dim dtoNGUOIDUNG As NGUOIDUNGdto = LayBangDTo(i, Dao)
            aList.Add(dtoNGUOIDUNG)
        Next
        Return aList
    End Function
    Public Function LayBangTableTheoID(ByVal ID As System.Int32) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoID(ID)
        Return Dao
    End Function
    Public Function LayBangTableTheoID(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoID(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoID(ByVal ID As System.Int32)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.XOABangTheoID(ID)
    End Sub
    Public Function LayBangTableTheoTenDangNhap(ByVal TenDangNhap As System.String) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoTenDangNhap(TenDangNhap)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenDangNhap_like(ByVal TenDangNhap As System.String) As DataTable
        Dim Dao As New NGUOIDUNGDao(ketnoi)
        Dao.layBangTheoTenDangNhap_like(TenDangNhap)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenDangNhap(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoTenDangNhap(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoTenDangNhap(ByVal TenDangNhap As System.String)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.XOABangTheoTenDangNhap(TenDangNhap)
    End Sub
    Public Function LayBangTableTheoMatKhau(ByVal MatKhau As System.String) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoMatKhau(MatKhau)
        Return Dao
    End Function
    Public Function LayBangTableTheoMatKhau_like(ByVal MatKhau As System.String) As DataTable
        Dim Dao As New NGUOIDUNGDao(ketnoi)
        Dao.layBangTheoMatKhau_like(MatKhau)
        Return Dao
    End Function
    Public Function LayBangTableTheoMatKhau(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoMatKhau(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoMatKhau(ByVal MatKhau As System.String)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.XOABangTheoMatKhau(MatKhau)
    End Sub
    Public Function LayBangTableTheoIdNV(ByVal IdNV As System.Int32) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoIdNV(IdNV)
        Return Dao
    End Function
    Public Function LayBangTableTheoIdNV(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoIdNV(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoIdNV(ByVal IdNV As System.Int32)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.XOABangTheoIdNV(IdNV)
    End Sub
    Public Function LayBangTableTheoIdQuyen(ByVal IdQuyen As System.Int32) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoIdQuyen(IdQuyen)
        Return Dao
    End Function
    Public Function LayBangTableTheoIdQuyen(ByVal ARRAY1 As ArrayList) As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangTheoIdQuyen(ARRAY1)
        Return Dao
    End Function
    Public Sub XOAbangTableTheoIdQuyen(ByVal IdQuyen As System.Int32)
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.XOABangTheoIdQuyen(IdQuyen)
    End Sub
    Public Function LayBangDTo(ByVal tennguoidung As System.String) As NGUOIDUNGdto
        Dim Dao As New NGUOIDUNGDao(ketnoi)
        Dao.layBangTheoTenDangNhap(tennguoidung)
        Dim dto As New NGUOIDUNGdto
        If Dao.Rows.Count <= 0 Then Return dto
        Try
            If IsDBNull(Dao.Rows(0)("ID")) = False Then
                dto.ID = Dao.Rows(0)("ID")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("TenDangNhap")) = False Then
                dto.TenDangNhap = Dao.Rows(0)("TenDangNhap")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("MatKhau")) = False Then
                dto.MatKhau = Dao.Rows(0)("MatKhau")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("IdNV")) = False Then
                dto.IdNV = Dao.Rows(0)("IdNV")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("IdQuyen")) = False Then
                dto.IdQuyen = Dao.Rows(0)("IdQuyen")
            End If
        Catch ex As Exception
        End Try
        Return dto
    End Function
    Public Function LayBangDTo(ByVal ID As System.Int32) As NGUOIDUNGdto
        Dim Dao As New NguoidungDao(ID, ketnoi)
        Dim dto As New NGUOIDUNGdto
        If Dao.Rows.Count <= 0 Then Return dto
        Try
            If IsDBNull(Dao.Rows(0)("ID")) = False Then
                dto.ID = Dao.Rows(0)("ID")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("TenDangNhap")) = False Then
                dto.TenDangNhap = Dao.Rows(0)("TenDangNhap")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("MatKhau")) = False Then
                dto.MatKhau = Dao.Rows(0)("MatKhau")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("IdNV")) = False Then
                dto.IdNV = Dao.Rows(0)("IdNV")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(Dao.Rows(0)("IdQuyen")) = False Then
                dto.IdQuyen = Dao.Rows(0)("IdQuyen")
            End If
        Catch ex As Exception
        End Try
        Return dto
    End Function
    Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As NGUOIDUNGdto
        Dim dto As New NGUOIDUNGdto
        If dao.Rows.Count <= 0 Then Return dto
        Try
            If IsDBNull(dao.Rows(i)("ID")) = False Then
                dto.ID = dao.Rows(i)("ID")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("TenDangNhap")) = False Then
                dto.TenDangNhap = dao.Rows(i)("TenDangNhap")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("MatKhau")) = False Then
                dto.MatKhau = dao.Rows(i)("MatKhau")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("IdNV")) = False Then
                dto.IdNV = dao.Rows(i)("IdNV")
            End If
        Catch ex As Exception
        End Try
        Try
            If IsDBNull(dao.Rows(i)("IdQuyen")) = False Then
                dto.IdQuyen = dao.Rows(i)("IdQuyen")
            End If
        Catch ex As Exception
        End Try
        Return dto
    End Function
    Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As NGUOIDUNGdto
        Dim dto As New NGUOIDUNGdto
        If dao.Rows.Count <= 0 Then Return dto
        For cot As Integer = 0 To dao.Columns.Count - 1
            Try
                dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
            Catch ex As Exception
            End Try
        Next
        Return dto
    End Function
    Public Function layBangNhieuTable() As DataTable
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.layBangNhieuTable()
        Return Dao
    End Function
    Public Sub Taotable()
        Dim Dao As New NguoidungDao(ketnoi)
        Dao.TaoTable()
    End Sub
#Region "khac"
    Public Function LayBangTable(ByVal cauhoi1 As String, ByVal traloi1 As String, ByVal cauhoi2 As String, ByVal traloi2 As String) As DataTable
        Dim Dao As New NGUOIDUNGDao(ketnoi)
        Dao.layBang(cauhoi1, traloi1, cauhoi2, traloi2)
        Return Dao
    End Function
    Public Function LayBangTableTheoTenDangNhapMatkhau(ByVal TenDangNhap As String, ByVal matkhau As String) As DataTable
        Dim Dao As New NGUOIDUNGDao(ketnoi)
        Dao.layBangTheoTenDangNhapMatkhau(TenDangNhap, matkhau)
        Return Dao
    End Function
#End Region
End Class

